package FrameWork.PathFinding;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class TestPathFinding{
	public static void main(String[] args){
		JFrame frame = new JFrame("test");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(800, 800);
		PathfindPanel pp = new PathfindPanel();
		frame.add(pp);
		
		JPanel southPanel = new JPanel();
		
		southPanel.add(new JLabel("size: "));
		JTextField sizeField = new JTextField("100");
		sizeField.setColumns(4);
		southPanel.add(sizeField);
		
		southPanel.add(new JLabel("scale: "));
		JTextField scaleField = new JTextField("5");
		scaleField.setColumns(3);
		southPanel.add(scaleField);
		
		southPanel.add(new JLabel("H value: "));
		JTextField HField = new JTextField("1");
		HField.setColumns(2);
		southPanel.add(HField);
		
		JButton reset = new JButton("reset");
		reset.addActionListener(new ActionListener() {
			private JTextField sizeField;
			private JTextField scaleField;
			private JTextField HField;
			private PathfindPanel pp;
			private JFrame frame;
			public ActionListener setops(JTextField sizeField,JTextField scaleField,JTextField HField,PathfindPanel pp,JFrame frame){
				this.scaleField=scaleField;
				this.sizeField=sizeField;
				this.HField=HField;
				this.pp=pp;
				this.frame=frame;
				return this;
			}
			@Override
			public void actionPerformed(ActionEvent e) {
				pp.size = Integer.parseInt(sizeField.getText());
				pp.scale = Integer.parseInt(scaleField.getText());
				pp.nodeMap.getHeuristic().setHValue(Integer.parseInt(HField.getText()));
				pp.initMap();
				frame.repaint();
			}
		}.setops(sizeField,scaleField,HField,pp,frame));
		southPanel.add(reset);
		
		
		frame.add(southPanel,BorderLayout.SOUTH);
		
		frame.setVisible(true);
	}
}
